home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / CRS / crs53.d81 / 28may87s.pma / CX80.ASM < prev    next >
Assembly Source File  |  1979-12-31  |  7KB  |  350 lines

  1.  
  2.  
  3.     title    'CX40 & CX80   40 and 80 column drivers    18 Feb 86'
  4.  
  5.     maclib    cxequ
  6.  
  7.     maclib    z80
  8.  
  9.  
  10. lines    equ    24
  11.  
  12. ;    public    ?fundir            ; function direct
  13.  
  14.     public    ?int40,?int80
  15.     public    ?stat,?save,?recov,@st40
  16.  
  17.     extrn    ADM31,setadm
  18. ;    extrn    setvt
  19.  
  20.     page
  21. ;
  22. ;**
  23. ;**    This is the entry point to get to the function module
  24. ;** 
  25. ;
  26. ;
  27. ;    This code will perform the functions that the emulation
  28. ;    code will need to do to complete function.
  29. ;
  30. ;
  31. ;
  32. ;
  33. ;    enable  cursor,  then set foreground and background colors  
  34. ;
  35.     DSEG
  36. ?int80:
  37.     call    setadm
  38.     lhld    key$tbl            ; logical color assignments at end of
  39.     lxi    d,11*4*8        ; ..key$table, (key$tbl size=11*4*8)
  40.     dad    d
  41.     shld    color$tbl$ptr        ; setup color table ptr
  42.  
  43.     mvi    a,80h
  44.     sta    current$atr
  45.  
  46. ;
  47. ;    program the 8563 for full flashing cursor
  48. ;
  49.     mvi    a,10            ; point to cursor start line#
  50.     call    R$wait            ;  and mode register
  51.     mvi    a,40h            ; start at line zero, cursor 1/16
  52.     outp    a
  53.     mvi    a,11            ; point to cursor end line#
  54.     call    R$wait
  55.     mvi    a,7
  56.     outp    a
  57.     ret
  58.  
  59.     page
  60. ;
  61. ;
  62. ;
  63.     DSEG
  64. ?int40:
  65.     lxi    h,screen$40
  66.     shld    char$adr$40
  67.  
  68.     mvi    a,24
  69.     sta    paint$size        ; set 40 column repaint to 24 lines
  70.  
  71.     lxi    b,VIC+18h        ; point to address register
  72.     mvi    a,vic$screen*4/256+6    ; upper and lower case set (+6)
  73.     outp    a            ; move screen
  74.     ret
  75.  
  76.  
  77. ;**
  78. ;**    The following code is used to maintain the status line on
  79. ;**    both the 80 and 40 column displays
  80. ;**
  81. ;
  82. ;    save characters on the status line (80 column only) to buffer
  83. ;    reverse video the data area cleared (40 and 80 column screens)
  84. ;
  85. ;    C=start column #    B=number of characters to save
  86. ;
  87.     DSEG
  88. ?save:
  89.     mov    a,c
  90.     cpi    40
  91.     jrnc    do$save$80
  92.  
  93.     push    b
  94. ;;;***
  95.     mov    a,b
  96.     lxi    h,stat$line$40
  97.     mvi    b,0
  98.     dad    b
  99.  
  100. clear$loop$40:
  101.     mvi    m,' '+80h        ; set reverse video
  102.     inx    h
  103.     dcr    a
  104.     jrnz    clear$loop$40
  105.     call    paint$40$status
  106. ;;;***
  107.     pop    b
  108.  
  109. do$save$80:
  110.     mov    a,b
  111.     lxi    h,lines*80        ; point to status line
  112.     lxi    d,buffer$80$col        ; point to save buffer
  113.     mvi    b,0            ; zero MSB
  114.     dad    b            ; point to char position to save
  115.  
  116. save$loop:
  117.     push    psw            ; save count
  118.     push    d            ; save buffer address
  119.     call    R$read$memory        ; read char(B) and attribute(A)
  120.     pop    d            ; recover buffer pointer
  121.     stax    d            ; save character
  122.     inx    d            ; advance buffer
  123.     mov    a,b            ; get atrb to A
  124.     stax    d            ; save atrb
  125.     inx    d            ; advance buffer
  126.     push    d
  127.  
  128.     mvi    a,01000000b        ; reverse video only
  129.     call    get$atr$color        ; returned in A
  130.     mvi    d,' '            ; get character
  131.     call    R$write$memory
  132.  
  133.     pop    d
  134.     pop    psw            ; recover count
  135.     inx    h
  136.     dcr    a            ; adjust count
  137.     jrnz    save$loop        ; loop if not done
  138.     ret
  139.  
  140.     page
  141. ;
  142. ;    recover characters to the status line (80 column only)
  143. ;    for the 40 column screen just clear status line (with spaces)
  144. ;
  145. ;    C=start column #    B=number of characters to restore
  146. ;
  147.     DSEG
  148. ?recov:
  149.     mov    a,c
  150.     cpi    40
  151.     jrnc    recove$80        ; skip 40 column if C>40
  152.  
  153.     push    b
  154. ;;;***
  155.     lxi    h,stat$line$40
  156.     mov    a,b
  157.     mvi    b,0
  158.     dad    b
  159.     mov    b,a
  160.  
  161. recov$40$loop:
  162.     mvi    m,' '
  163.     inx    h
  164.     djnz    recov$40$loop
  165.     call    paint$40$status 
  166. ;;;***
  167.     pop    b
  168.  
  169. recove$80:
  170.     mov    a,b
  171.     lxi    h,lines*80        ; point to status line
  172.     lxi    d,buffer$80$col        ; point to save buffer
  173.     mvi    b,0            ; zero MSB
  174.     dad    b            ; point to char position to save
  175.  
  176. recov$80$loop:
  177.     push    psw            ; save count
  178.     ldax    d            ; get attribute
  179.     inx    d            ; advance pointer
  180.     mov    b,a            ; save attribute in B
  181.     ldax    d            ; get character in A
  182.     inx    d            ; advance pointer
  183.     push    d            ; save buffer address
  184.     mov    d,a            ; move character to D
  185.     mov    a,b            ; move attribute to A
  186.     call    R$write$memory        ; write char(D) and attribute(A)
  187.     pop    d            ; recover buffer pointer
  188.     pop    psw            ; recover count
  189.     inx    h
  190.     dcr    a            ; adjust count
  191.     jrnz    recov$80$loop        ; loop if not done
  192.     ret
  193.  
  194.     page
  195. ;
  196. ;    Places data on the system status line
  197. ;
  198. ;    for the 80 column screen a number of character attributes
  199. ;    are available: flash, underline, reverse video
  200. ;
  201. ;    for the 40 column screen only reverse video is available
  202. ;
  203. ;    INPUT:
  204. ;        A=attribute  (7654 3210)
  205. ;            6-reverse video
  206. ;            5-underline
  207. ;            4-blink
  208. ;        B=character to write (ASCII)
  209. ;        C=column number to write
  210. ;            (>40 does nothing to 40 column screen)
  211. ;
  212.     DSEG
  213. ?stat:
  214.     push    psw
  215.     push    b            ; save for 80 column display
  216.     mov    e,a            ; save attribute in E
  217.     mov    a,c
  218.     cpi    40
  219.     jrnc    not$40$col$wr
  220.  
  221. ;;;***
  222. ;
  223. ;    display on 40 column display 1st
  224. ;
  225.     RCALL    FR$ASCII$to$pet        ; char to convert is in B
  226.                     ; returned in A
  227.     mov    b,a
  228.     mov    a,e            ; get attribute byte
  229.     ani    01000000b        ; check for reverse video
  230.     mov    a,b            ; get pet ascii character
  231.     jrz    char$not$rev
  232.     ori    80h            ; set MSB for reverse video
  233. char$not$rev:
  234.     mvi    b,0
  235.     lxi    h,stat$line$40
  236.     dad    b            ; point to status position
  237.     mov    m,a    
  238.     call    paint$40$status
  239. ;;;***
  240.  
  241. ;
  242. ;    display on 80 column display now
  243. ;
  244. not$40$col$wr:
  245.     pop    d            ; D=character  E=position
  246.     pop    psw            ; get new attribute
  247.     call    get$atr$color
  248.  
  249.     mov    b,d            ; save character to write in B
  250.     lxi    h,lines*80
  251.     mvi    d,0
  252.     dad    d            ; point to character location
  253.     mov    d,b            ; place character to write in D
  254.     jmp    R$write$memory
  255.  
  256.  
  257. ;
  258. ;    using attribute in A add color to it and return in A
  259. ;
  260. ;    destroys BC
  261. ;
  262.     DSEG
  263. get$atr$color:
  264.     push    h
  265.     push    psw
  266.     lda    bg$color$80
  267.     mov    c,a
  268.     mvi    b,0
  269.     lxi    h,status$color$tbl
  270.     dad    b            ; point to status color 
  271.     pop    psw
  272.     ani    01110000b        ; limit good attr
  273.     mov    b,a            ; save in E
  274.     mov    a,m            ; get status color
  275.     ani    0fh            ; only want 80 column status color
  276.     ora    b            ; merge with new attr
  277.     ori    80h            ; select alternate character set
  278.     pop    h
  279.     ret
  280.  
  281. ;
  282. ;
  283. ;
  284.     DSEG
  285. paint$40$status:
  286.     lxi    h,stat$line$40
  287.     lxi    d,vic$screen+24*40
  288.     lxi    b,40
  289.     ldir
  290.  
  291.     lda    bg$color$40
  292.     mov    c,a
  293.     mvi    b,0
  294.     lxi    h,status$color$tbl
  295.     dad    b
  296.     mov    a,m
  297.     rrc
  298.     rrc                ; move status color to LSB
  299.     rrc                ; no need to mask it
  300.     rrc                ; color RAM only 4 bits wide
  301.  
  302.     lxi    h,vic$color+24*40
  303.     lxi    d,vic$color+24*40+1
  304.     lxi    b,40
  305.     jmp    paint$common
  306.  
  307. ;
  308. ;
  309. ;
  310.     CSEG
  311. paint$common:
  312.     sta    io$0
  313.     mov    m,a
  314.     ldir
  315.     sta    bank$0
  316.     ret
  317.  
  318.     page
  319. ;
  320. ;
  321. ;
  322. @st40:
  323. stat$line$40:
  324. ;         12345678901234567890   character locations
  325.     db    '                    '
  326.     db    '                    '
  327.  
  328. ;
  329. ;    MSB is 40 column status color, LSB is 80 column status color
  330. ;
  331. status$color$tbl:
  332.     db    05eh            ; status color #1
  333.     db    0f6h            ; status color #2
  334.     db    0a6h            ; status color #3
  335.     db    0b7h            ; status color #4
  336.     db    0d7h            ; status color #5
  337.      db    0d4h            ; status color #6
  338.     db    0e7h            ; status color #7
  339.     db    083h            ; status color #8
  340.     db    097h            ; status color #9
  341.     db    0a8h            ; status color #10
  342.     db    09eh            ; status color #11
  343.     db    0ffh            ; status color #12
  344.     db    0bdh            ; status color #13
  345.     db    058h            ; status color #14
  346.     db    06fh            ; status color #15
  347.     db    0ceh            ; status color #16
  348.  
  349.  
  350.